<!-- application/views/scripts/onlinelibrary/index.phtml -->
<?php $this->headScript()->appendFile($this->baseUrl("/js/onlinelibrary/script.js")); ?>
<?php $this->headLink()->appendStylesheet($this->baseUrl('/css/onlinelibrary/style.css')); ?>
<?php 
$menu = $this->guiElements()->menu()->setDecorator(X_VlcShares_Skins_Manager::i()->getDecorator(X_VlcShares_Skins_Manager::MENU_CONTEXTUAL));
$this->layout()->subNavigator =	$menu
	->addLinkRoute(X_Env::_('p_onlinelibrary_manage_add_new_entry'), "onlinelibrary", "add");
if ( $this->rtmpEnabled ) {
$this->layout()->subNavigator	
	->addLinkRoute(X_Env::_('p_onlinelibrary_manage_add_new_rtmp'), "onlinelibrary", "addrtmp");
}
	
$breadcrumb = $this->guiElements()->menu()->setDecorator(X_VlcShares_Skins_Manager::i()->getDecorator(X_VlcShares_Skins_Manager::MENU_BREADCRUMB));
/* @var $breadcrumb X_VlcShares_Elements_Menu */
$this->layout()->breadcrumb = $breadcrumb
	->addLinkRoute(X_Env::_('Dashboard'), 'manage', 'index')
	->addLabel(X_Env::_('p_onlinelibrary_manage_title'));
	
	
$this->headTitle()->prepend(X_Env::_('p_onlinelibrary_manage_title'));

?>
<?php $this->headScript()->captureStart(Zend_View_Helper_Placeholder_Container_Abstract::PREPEND); ?>
	var str_p_onlinelibrary_manage_newcategoryname = "<?php echo X_Env::_('p_onlinelibrary_manage_newcategoryname') ?>";
<?php $this->headScript()->captureEnd(); ?>


<?php if ( count($this->messages) ) :?>
<div class="span-24 last" id="manage-messages">
	<ul>
		<?php foreach ($this->messages as $i => $message ): ?>
			<?php if ( !is_array($message) ) $message = array('text' => $message, 'type' => 'warning'); ?>
			<li class="<?php echo @$message['type']?>">
				<img src="<?php echo @$this->baseUrl("/images/msg_{$message['type']}.png");?>" alt="<?php echo @$message['type']; ?>" />
				<?php echo $message['text']?>
			</li>
		<?php endforeach; ?>
	</ul>
</div>
<?php endif; ?>


<div class="unit columns on-2">
	<div class="elastic column">
		<div class="container">
			<div class="box">
				<div class="header">
					<span class="title"><?php echo X_Env::_('p_onlinelibrary_manage_title')?></span>
				</div>
				<div class="content">
					<table class="table" id="onlinelibrary-categories">
						<tr class="header">
							<th><?php echo X_Env::_('p_onlinelibrary_categoriestable_header_label')?></th>
							<th width="100px"><?php echo X_Env::_('p_onlinelibrary_categoriestable_header_num')?></th>
							<th width="100px"><?php echo X_Env::_('table_options')?></th>
						</tr>
						<?php if ( count($this->categories) ): ?>
							<?php foreach ($this->categories as $i => $category): ?>
								<tr class="<?php echo $i % 2 ? 'alt' : ''; ?>">
									<td>
										<a href="<?php echo $this->url(array(
												'controller' => 'onlinelibrary',
												'action'	=> 'category',
												'id'	=> X_Env::encode($category['category'])
											), 'default', true); ?>">
											<?php echo $category['category']; ?>
										</a>
									</td>
									<td><?php echo $category['links'];?></td>
									<td>
										<ul class="inline-menu">
											<li class="ui-state-default">
												<a class="ui-icon ui-icon-pencil onlinelibrary-category-rename" href="<?php echo $this->url(array(
													'controller' => 'onlinelibrary',
													'action' => 'rename',
													'id' => X_Env::encode($category['category']),
													'name' => ''
												), 'default', true); ?>">R</a>
											</li>
											<li class="ui-state-default">
												<a class="ui-icon ui-icon-trash" href="<?php echo $this->url(array(
													'controller' => 'onlinelibrary',
													'action' => 'delete',
													'type' => 'category',
													'id' => X_Env::encode($category['category']),
													'name' => ''
												), 'default', true); ?>">E</a>
											</li>
										</ul>
									</td>
								</tr>
							<?php endforeach; ?>
						<?php else: ?>
							<tr>
								<td colspan="3">
									<center>
										<i><?php echo X_Env::_('p_onlinelibrary_nocategories'); ?></i>
									</center>
								</td>
							</tr>
						<?php endif;?>
					</table>
					<?php if ( $this->pages > 1 ) : ?>
						<center>
							<ul class="paginator">
								<?php for ($i = 1; $i <= $this->pages; $i++ ): ?>
									<li>
										<?php if ( $i != $this->page ) : ?>
											<a href="<?php echo $this->url(array(
												'controller' => 'onlinelibrary',
												'action'	=> 'index',
												'page'	=> ($i == 1 ? null : $i)
											),'default', true)?>"><?php echo $i; ?></a>
										<?php else: ?>
											<?php echo $i; ?>
										<?php endif;?>
									</li>
								<?php endfor; ?>
							</ul>
						</center>
					<?php endif; ?>					
				</div>
			</div>
		</div>
	</div>
		<div class="fixed column" style="width: 400px">
			<div class="container">
				<?php if ( $this->bookmarkletsEnabled ) : ?>
					<div class="box" id="onlinelibrary-bookmarklets">
						<div class="header">
							<span class="title"><?php echo X_Env::_('p_onlinelibrary_manage_bookmarkletstitle')?></span>
						</div>
						<div class="content">
							<?php echo $this->action('index', 'bookmarklets'); ?>
						</div>
					</div>
				<?php endif; ?>
				<div class="box" id="onlinelibrary-hosters">
					<div class="header">
						<span class="title"><?php echo X_Env::_('p_onlinelibrary_manage_supportedhoster')?></span>
					</div>
					<div class="content">
						<?php foreach ($this->hosters as $hosterId => $pattern ): ?>
							<img title="<?php echo ucfirst($hosterId) . " - Pattern: ". htmlentities($pattern) ?>" 
								src="<?php echo $this->baseUrl("/images/icons/hosters/$hosterId.png")?>"
								alt="<?php echo $hosterId?>"
								width="32px"
								height="32px" style="margin: 0.5em;" />
						<?php endforeach; ?>
					</div>
				</div>
			</div>
		</div>
</div>
